<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>JWChat - 用户邀请请求</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <script src="shared.js"></script>
    <script src="emoticons.js"></script>
    <script src="switchStyle.js"></script>
    <script src="jsjac.js"></script>
    <script>
      <!--
var jid;
var msg;
var srcW; // the source window with necessary data

function sendSub() {
  var aPresence = new JSJaCPresence();
  aPresence.setTo(jid);
  aPresence.setType('subscribed');

  srcW.con.send(aPresence);

  // maybe we want to subscribe to?

  var user = srcW.roster.getUserByJID(jid);
  if (!user || (user.subscription != 'both' && user.subscription != 'to'))
    srcW.openSubscription(jid);

  window.close();
}

function sendUnsub() {
  var aPresence = new JSJaCPresence();
  aPresence.setTo(jid);
  aPresence.setType('unsubscribed');

  window.close();
}    

function init() {
  // determine source window
  srcW = opener;
			
  getArgs();
  jid = passedArgs['jid'];
  if (typeof(passedArgs['msg']) != 'undefined')
    msg = passedArgs['msg'];

  document.title = "从 "+jid+" 来的邀请请求";

  var from = "<b><span class=\"link\" onClick=\"return srcW.openUserInfo('"+jid+"');\" title=\""+"显示用户 "+jid+" 的信息"+"\">"+jid.substring(0,jid.indexOf('@'))+"</a></b> ";
  
  document.getElementById("requestingUser").innerHTML = from;
  if (msg)
    msgbox.document.body.innerHTML = msgFormat(msg);
}
		
function keyPressed(e) {
  if (e.ctrlKey && e.keyCode == 13)
    sendSub();
  else if (e.keyCode == 27)
    window.close();
}

onkeydown = keyPressed;
onload = init;
      //-->
    </script>
    <script for="document" event="onkeydown()" language="JScript">
      <!--
      if (window.event.ctrlKey && window.event.keyCode == 13)
      sendSub();
      if (window.event.keyCode == 27)
      window.close();
      //-->
    </script>
  </head>
  <body style="margin:8px;">
    <table  width="100%" height="100%" border=0 cellpadding=0 cellspacing=0 style="margin-bottom: 8px;">
      <tr><td>
        <span id="requestingUser"></span> 想加您为他/她的联系人:
      </td></tr>
      <tr height="100%"><td style="padding-top: 4px;"><iframe src="chat_iframe.html" id="msgbox" name="msgbox" scrolling="yes" class="msgbox"></iframe></td></tr>
      <form name="sub">
      <tr><td><hr noshade size="1" size="100%"></td></tr>
      <tr><td align="right">
          <button onClick="return sendUnsub();">阻止</button>&nbsp;<button onClick="return sendSub();" tabindex=1>允许</button>
        </td></tr>
      </form>
    </table>
  </body>
</html>
